package com.webchat.client.mall.controller.im;


import com.webchat.client.mall.service.im.MallChatMessageService;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.config.annotation.ValidateLogin;
import com.webchat.common.helper.SessionHelper;
import com.webchat.domain.vo.dto.mall.im.UgcServerMessageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mall-service/im/message")
public class MallChatMessageController {


    @Autowired
    private MallChatMessageService mallChatMessageService;

    /**
     * 智能客服系统对话消息列表查询接口
     *
     * @return
     */
    @ValidateLogin
    @GetMapping("/list")
    public APIResponseBean<List<UgcServerMessageDTO<Object>>> list(
            @RequestParam(value = "chatAccount", required = false) String chatAccount,
            @RequestParam(value = "lastTime", required = false) Long lastTime,
            @RequestParam(value = "size", required = false, defaultValue = "20") int size,
            @RequestParam(value = "loadScreenNo") int loadScreenNo) {

        String account = SessionHelper.getCurrentUserId();
        List<UgcServerMessageDTO> res = mallChatMessageService.list(account, chatAccount, lastTime, size, loadScreenNo);
        return APIResponseBeanUtil.success(res);
    }

}
